from django.db import models
from datetime import datetime
from django.utils import timezone

# 基类
class Base(models.Model):
    # 创建时间
    create_time = models.DateTimeField(default=timezone.now, null=True)

    class Meta:
        abstract = True

#无限极分类
class Cate(models.Model):

	#分类名称
	name = models.CharField(max_length=500)
	#父id
	pid = models.IntegerField()

	class Meta:
		db_table = 'cate'

# 用户类
class User(Base):
    # 用户名
    username = models.CharField(max_length=200)
    # 密码
    password = models.CharField(max_length=200)
    # 头像
    img = models.CharField(max_length=200)
    # 类别 0用户 1管理员
    type = models.IntegerField(default=0, null=True)

    class Meta:
        db_table = 'user'

# 幻灯片类
class Pics(Base):
    # 名称
    title = models.CharField(max_length=200)
    # 链接
    link = models.CharField(max_length=200)
    # 图片
    img = models.CharField(max_length=200)

    class Meta:
        db_table = 'pics'

# 商品表
class Goods(Base):
    # 商品名称
    name = models.CharField(max_length=200)
    # 商品简介
    desc = models.CharField(max_length=500)
    # 商品规格
    parms = models.CharField(max_length=200)
    # 商品头图
    img = models.CharField(max_length=200, null=True)
    # 演示视频
    video = models.CharField(max_length=200, null=True)
    # 价格
    price = models.IntegerField()
    # 关注数
    flow = models.IntegerField(default=0, null=True)
    # 分类id
    cate_id = models.IntegerField()

    class Meta:
        db_table = 'goods'

# 用户评论表
class Comment(Base):
    # 评论内容
    content = models.CharField(max_length=200)
    # 谁评论的
    uid = models.IntegerField()
    # 评论的哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'comment'

# 关注表
class UserFlow(Base):
    # 谁关注的
    uid = models.IntegerField()
    # 关注的那个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'userflow'
